//
//  ViewController.m
//  TLAVPlayer
//
//  Created by tianlong on 2019/5/14.
//  Copyright © 2019年 tianlong. All rights reserved.
//

#import "ViewController.h"
#import "TLPlayViewController.h"
#import "TLScrollPlayViewController.h"
#import "Masonry.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) UITableView *tableView;
@property (nonatomic , strong) NSMutableArray *dataM;
@end

@implementation ViewController

static NSString *cellID = @"CellID";
static NSString *testPlayer = @"调试播放器";
static NSString *scrollPlay = @"滚动播放";

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    //self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
    self.dataM  = [NSMutableArray arrayWithObjects:testPlayer,scrollPlay, nil];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.offset(0);
    }];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataM.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    cell.textLabel.text = self.dataM[indexPath.row];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row < self.dataM.count) {
        NSString *str = self.dataM[indexPath.row];
        
        UIViewController *detailVC = nil;
        if ([str isEqualToString:testPlayer]) {
            detailVC = [[TLPlayViewController alloc] init];
        }
        else if ([str isEqualToString:scrollPlay]){
            detailVC = [[TLScrollPlayViewController alloc] init];
        }
        [self.navigationController pushViewController:detailVC animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
